package com.desay.pangoo.itmt.entity;

import java.io.Serializable;
import java.util.Objects;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import lombok.Data;

/**
 * roadMap_yearQuarter
 * 
 * @author uidq1163
 *
 */
@Entity
@EntityListeners(AuditingEntityListener.class)
@Table(name = "tech_yearQuarter__history")
@Data
@JsonIgnoreProperties({"techProject"})
public class TechYearQuarterHistoryEntity extends BaseEntity implements Serializable {


	private static final long serialVersionUID = -3938803712902738543L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "id", columnDefinition = "bigint COMMENT '主键'")
	private Long id;

	@Column(name = "status", nullable = false, columnDefinition = "int COMMENT '状态：1:plan 2:on'")
	private Integer status;

	@Column(name = "year", nullable = false, columnDefinition = "int COMMENT '时间：年'")
	private Integer year;

	@Column(name = "quarter", nullable = false, columnDefinition = "int COMMENT '时间：季度'")
	private Integer quarter;

	@ManyToOne(fetch = FetchType.EAGER, optional = true)
	@JoinColumn(name = "tech_project_id")
	@JsonIgnoreProperties
	private TechProjectInfoHistoryEntity techProject;

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (!super.equals(obj)) {
			return false;
		}
		if (getClass() != obj.getClass()) {
			return false;
		}
		TechYearQuarterHistoryEntity other = (TechYearQuarterHistoryEntity) obj;
		return Objects.equals(quarter, other.quarter) && Objects.equals(status, other.status)
				&& Objects.equals(year, other.year);
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = super.hashCode();
		result = prime * result + Objects.hash(quarter, status, year);
		return result;
	}

}
